import Cookies from "js-cookie";
import store from "@/store";

// const TokenKey = "vip-auth-token-admin";
const TokenKey2 = "yuntk-auth-token-admin";

export function getToken() {
    return /*Cookies.get(TokenKey) || */Cookies.get(TokenKey2);
}

export function removeToken() {
    return /*Cookies.remove(TokenKey) ||*/ Cookies.remove(TokenKey2);
}

export function removeInfo() {
    store.state.currentUser = null;
    store.state.user.roles = null;
}
export function AES_CBC_ENCRYPT(text, publicKey) {

    const phone = '';
    const textHex = CryptoJS.enc.Utf8.parse(text);

    const key = CryptoJS.enc.Utf8.parse(publicKey);
    const iv = CryptoJS.enc.Utf8.parse(phone);
    const encryptedContent = CryptoJS.AES.encrypt(textHex, key, {
        // iv: iv,
        mode: CryptoJS.mode.ECB
        // padding: CryptoJS.pad.Pkcs7
    });
    return encryptedContent.toString();
}
